﻿@using Orchard.Localization
@using Orchard.Utility.Extensions
@{
    var tabs = ((IEnumerable<dynamic>)Model.Tabs).ToArray();

    if (tabs.Any()) {
        Script.Require("LocalNavigation");
    }
}
@if (tabs.Any()) {
    var tabIndex = 0;
    <div id="local-navigation">
        <ul class="localmenu group">
            @foreach (var tab in tabs) {
                var tabText = tab is string ? (string)tab : (string)(tab.Text is LocalizedString ? tab.Text.ToString() : tab.Text);
                var defaultTabId = string.Format("tab-{0}", tabText.HtmlClassify());
                var tabId = tab is string ? defaultTabId : (string)(tab.TabName ?? defaultTabId);
                var tabCssClass = tabIndex == 0 ? "first selected" : tabIndex <= tabs.Count() - 1 ? "last" : "middle";
                <li class="@tabCssClass"><a href="#@tabId">@tabText</a></li>
                tabIndex++;
            }
        </ul>
    </div>
}